package com.videoStream.video;

import com.videoStream.video.cache.CacheUtil;
import com.videoStream.video.push.CameraPush;
import org.bytedeco.javacv.FFmpegFrameGrabber;
import org.bytedeco.javacv.FFmpegFrameRecorder;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;

import java.util.Date;

/**
 * @Author: wwy
 * @Date: 2022/7/5 9:05
 */
@SpringBootApplication
public class VideoStreamApplication {
    public static void main(String[] args) {
        new Thread(()->{
            // 服务启动执行FFmpegFrameGrabber和FFmpegFrameRecorder的tryLoad()，以免导致第一次推流时耗时。
            try {
                FFmpegFrameGrabber.tryLoad();
                FFmpegFrameRecorder.tryLoad();
            } catch (org.bytedeco.javacv.FrameRecorder.Exception e) {
                e.printStackTrace();
            } catch (Exception e) {
                e.printStackTrace();
            }
            // 将服务启动时间存入缓存
            CacheUtil.STARTTIME = System.currentTimeMillis();
        }).start();
        ApplicationContext applicationContext = SpringApplication.run(VideoStreamApplication.class);
        CameraPush.setApplicationContext(applicationContext);
    }
}
